<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => {
    assert_true(navigator.platform.indexOf('Mac') === 0,
        'This test requires MacOS for kill ring');

    assert_not_equals(window.testRunner, undefined,
        'This test requires testRunner');

    // Note: The orignal test used |eventSender.keyDown()| with Ctrl+A, Ctrl+K
    // and Ctrl+Y, but content_shell doesn't support mapping control key to menu
    // command. This test uses |testRunner.execCommand()| to verify menu
    // commands which mapped from key bindings.
    assert_selection(
        '<div contenteditable>one five| two three four</div>',
        (selection, testRunner) => {
            // "two three four" in the kill ring
            testRunner.execCommand('deleteToEndOfLine'); // Ctrl+K
            // cursor before "one"
            testRunner.execCommand('moveToBeginningOfLine'); // Ctrl+A
            // cursor after "one"
            selection.modify('move', 'forward', 'word');
            testRunner.execCommand('yank'); // Ctrl+Y
        },
        '<div contenteditable>one two three four| five</div>',
        'Verifies Ctrl+K, Ctrl+A, then Ctrl+Y for MacOS');
});
</script>
